import request from '@/utils/request'
import type { Login, LoginParams } from './model/login'
import { useInfoStore } from '@/store'

// const isCFJD = import.meta.env.MODE === 'cfjd'

export const login = async (data: LoginParams, flag = false) => {
  const userStore = useInfoStore()
  userStore.setShowHeader(true)
  return await request.post<Login | null>('login', {
    data,
    headers: {
      refreshToken: flag
    }
  })
}

export const logOut = async () => {
  return await request.delete<Login | null>('auth/token/logout')
}
// 获取登录人信息
export const getUserInfo = async (userId: number) => {
  return await request.get(`system/user/getById?userId=${userId}`)
}
